package main

import (
	"fmt"
	"strconv"
)

func main() {
	//练习golang语言 string类型转换为其它类型

	// 1. string转换为int
	var str string = "12345"
	var n1 int64
	n1, _ = strconv.ParseInt(str, 10, 64)
	fmt.Printf("n1 type %T n1=%v\n", n1, n1)

	// 2. string转换为float
	var str2 string = "123.456"
	var f1 float64
	f1, _ = strconv.ParseFloat(str2, 64)
	fmt.Printf("f1 type %T f1=%v\n", f1, f1)

	// 3. string转换为bool
	var str3 string = "true"
	var b bool
	b, _ = strconv.ParseBool(str3)
	fmt.Printf("b type %T b=%v\n", b, b)
}
